package org.zjx.service.impl;


import org.zjx.db.ScreenDB;
import org.zjx.model.game.Screen;
import org.zjx.service.ScreenService;

import java.awt.*;

public class ScreenServiceImpl implements ScreenService {
    @Override
    public Boolean isRoom(String screenName) {
        Screen screen = new ScreenDB().findByName(screenName);
        return screen != null && screen.getFatherId() != 0;
    }

    @Override
    public Point getScreenSize(String screenName) {
        Screen screen = new ScreenDB().findByName(screenName);
        if (screen == null) return new Point(0, 0);
        return new Point(screen.getWidth(), screen.getHeight());
    }

    @Override
    public Screen getScreen(String screenName) {
        return new ScreenDB().findByName(screenName);
    }

    @Override
    public Screen getScreenById(int screenId) {
        return new ScreenDB().findById(screenId);
    }
}
